home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / cpu / tms32010 / tms32010.h < prev   
C/C++ Source or Header  |  1999-04-08  |  6KB  |  141 lines

  1. /****************************************************************************
  2.  *                    Texas Instruments TMS320C10 DSP Emulator                *
  3.  *                                                                            *
  4.  *                        Copyright (C) 1999 by Quench                        *
  5.  *        You are not allowed to distribute this software commercially.        *
  6.  *                        Written for the MAME project.                        *
  7.  *                                                                            *
  8.  *                Note: This is a word based microcontroller.                    *
  9.  ****************************************************************************/
  10.  
  11. #ifndef _TMS320C10_H
  12. #define _TMS320C10_H
  13.  
  14. /*************************************************************************
  15.  * If your compiler doesn't know about inlined functions, uncomment this *
  16.  *************************************************************************/
  17.  
  18. /* #define INLINE static */
  19.  
  20. #include "osd_cpu.h"
  21. #include "osd_dbg.h"
  22. #include "cpuintrf.h"
  23.  
  24. enum {
  25.     TMS320C10_PC=1, TMS320C10_SP, TMS320C10_STR, TMS320C10_ACC,
  26.     TMS320C10_PREG, TMS320C10_TREG, TMS320C10_AR0, TMS320C10_AR1,
  27.     TMS320C10_STK0, TMS320C10_STK1, TMS320C10_STK2, TMS320C10_STK3
  28. };
  29.  
  30. extern    int tms320c10_ICount;        /* T-state count */
  31.  
  32. #define TMS320C10_ACTIVE_INT  0        /* Activate INT external interrupt         */
  33. #define TMS320C10_ACTIVE_BIO  1        /* Activate BIO for use with BIOZ inst     */
  34. #define TMS320C10_IGNORE_BIO  -1    /* Inhibit BIO polled external interrupt */
  35. #define    TMS320C10_PENDING      0x80000000
  36. #define TMS320C10_NOT_PENDING 0
  37. #define TMS320C10_INT_NONE      -1
  38.  
  39. #define  TMS320C10_ADDR_MASK  0x0fff    /* TMS320C10 can only address 0x0fff */
  40.                                         /* however other TMS320C1x devices     */
  41.                                         /* can address up to 0xffff (incase  */
  42.                                         /* their support is ever added).     */
  43.  
  44. void tms320c10_reset  (void *param);            /* Reset processor & registers    */
  45. void tms320c10_exit(void);                        /* Shutdown CPU core            */
  46. int tms320c10_execute(int cycles);                /* Execute cycles T-States -    */
  47.                                                 /* returns number of cycles actually run */
  48. unsigned tms320c10_get_context(void *dst);     /* Get registers            */
  49. void tms320c10_set_context(void *src);         /* Set registers            */
  50. unsigned tms320c10_get_pc(void);                /* Get program counter        */
  51. void tms320c10_set_pc(unsigned val);            /* Set program counter        */
  52. unsigned tms320c10_get_sp(void);                /* Get stack pointer        */
  53. void tms320c10_set_sp(unsigned val);            /* Set stack pointer        */
  54. unsigned tms320c10_get_reg(int regnum);            /* Get specific register    */
  55. void tms320c10_set_reg(int regnum, unsigned val);/* Set specific register    */
  56. void tms320c10_set_nmi_line(int state);
  57. void tms320c10_set_irq_line(int irqline, int state);
  58. void tms320c10_set_irq_callback(int (*callback)(int irqline));
  59. const char *tms320c10_info(void *context, int regnum);
  60. unsigned tms320c10_dasm(char *buffer, unsigned pc);
  61.  
  62. #include "memory.h"
  63.  
  64. /*     Input a word from given I/O port
  65.  */
  66. #define TMS320C10_In(Port) ((UINT16)cpu_readport(Port))
  67.  
  68.  
  69. /*     Output a word to given I/O port
  70.  */
  71. #define TMS320C10_Out(Port,Value) (cpu_writeport(Port,Value))
  72.  
  73.  
  74. /*     Read a word from given ROM memory location
  75.  * #define TMS320C10_ROM_RDMEM(A) READ_WORD(&ROM[(A<<1)])
  76.  */
  77. #ifdef LSB_FIRST
  78. #define TMS320C10_ROM_RDMEM(A) (unsigned)((cpu_readmem16((A<<1))<<8) | cpu_readmem16(((A<<1)+1)))
  79. #else
  80. #define TMS320C10_ROM_RDMEM(A) (unsigned)((cpu_readmem16((A<<1))) | cpu_readmem16(((A<<1)+1))<<8)
  81. #endif
  82.  
  83. /*     Write a word to given ROM memory location
  84.  * #define TMS320C10_ROM_WRMEM(A,V) WRITE_WORD(&ROM[(A<<1)],V)
  85.  */
  86. #ifdef LSB_FIRST
  87. #define TMS320C10_ROM_WRMEM(A,V) { cpu_writemem16(((A<<1)+1),(V&0xff)); cpu_writemem16((A<<1),((V>>8)&0xff)); }
  88. #else
  89. #define TMS320C10_ROM_WRMEM(A,V) { cpu_writemem16(((A<<1)+1),((V>>8)&0xff)); cpu_writemem16((A<<1),(V&0xff)); }
  90. #endif
  91.  
  92. /*     Read a word from given RAM memory location
  93.      The following adds 8000h to the address, since MAME doesnt support
  94.      RAM and ROM living in the same address space. RAM really starts at
  95.      address 0 and are word entities.
  96.  * #define TMS320C10_RAM_RDMEM(A) ((unsigned)cpu_readmem16lew_word(((A<<1)|0x8000)))
  97.  */
  98. #ifdef LSB_FIRST
  99. #define TMS320C10_RAM_RDMEM(A) (unsigned)((cpu_readmem16((A<<1)|0x8000)<<8) | cpu_readmem16(((A<<1)|0x8001)))
  100. #else
  101. #define TMS320C10_RAM_RDMEM(A) (unsigned)((cpu_readmem16((A<<1)|0x8000)) | cpu_readmem16(((A<<1)|0x8001))<<8)
  102. #endif
  103.  
  104. /*     Write a word to given RAM memory location
  105.      The following adds 8000h to the address, since MAME doesnt support
  106.      RAM and ROM living in the same address space. RAM really starts at
  107.      address 0 and word entities.
  108.  * #define TMS320C10_RAM_WRMEM(A,V) (cpu_writemem16lew_word(((A<<1)|0x8000),V))
  109.  */
  110. #ifdef LSB_FIRST
  111. #define TMS320C10_RAM_WRMEM(A,V) { cpu_writemem16(((A<<1)|0x8001),(V&0x0ff)); cpu_writemem16(((A<<1)|0x8000),((V>>8)&0x0ff)); }
  112. #else
  113. #define TMS320C10_RAM_WRMEM(A,V) { cpu_writemem16(((A<<1)|0x8001),((V>>8)&0x0ff)); cpu_writemem16(((A<<1)|0x8000),(V&0x0ff)); }
  114. #endif
  115.  
  116. /*     TMS320C10_RDOP() is identical to TMS320C10_RDMEM() except it is used for reading
  117.  *     opcodes. In case of system with memory mapped I/O, this function can be
  118.  *     used to greatly speed up emulation
  119.  */
  120. #ifdef LSB_FIRST
  121. #define TMS320C10_RDOP(A) (unsigned)((cpu_readop((A<<1))<<8) | cpu_readop(((A<<1)+1)))
  122. #else
  123. #define TMS320C10_RDOP(A) (unsigned)((cpu_readop((A<<1))) | cpu_readop(((A<<1)+1))<<8)
  124. #endif
  125.  
  126. /*     TMS320C10_RDOP_ARG() is identical to TMS320C10_RDOP() except it is used for reading
  127.  *     opcode arguments. This difference can be used to support systems that
  128.  *     use different encoding mechanisms for opcodes and opcode arguments
  129.  */
  130. #ifdef LSB_FIRST
  131. #define TMS320C10_RDOP_ARG(A) (unsigned)((cpu_readop_arg((A<<1))<<8) | cpu_readop_arg(((A<<1)+1)))
  132. #else
  133. #define TMS320C10_RDOP_ARG(A) (unsigned)((cpu_readop_arg((A<<1))) | cpu_readop_arg(((A<<1)+1))<<8)
  134. #endif
  135.  
  136. #ifdef    MAME_DEBUG
  137. extern unsigned Dasm32010(char *buffer, unsigned pc);
  138. #endif
  139.  
  140. #endif  /* _TMS320C10_H */
  141.